package com.crazyandroid.codeview;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.crazyandroid.R;

public class MixView extends Activity
{
	int[] images = new int[] { R.drawable.java, R.drawable.ee,
			R.drawable.classic, R.drawable.ajax, R.drawable.xml };
	int currentImg = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mix);

		LinearLayout main = (LinearLayout) findViewById(R.id.root);

		final ImageView image = new ImageView(this);
		main.addView(image);
		image.setImageResource(images[0]);
		image.setOnClickListener(new OnClickListener()
		{

			@Override
			public void onClick(View v)
			{
				if (currentImg >= 4)
				{
					currentImg = -1;
				}
				image.setImageResource(images[++currentImg]);
			}
		});

	}

}
